//
//  GameScene.m
//  618
//
//  Created by Ling on 13-6-21.
//  Copyright 2013年 __618工作室__. All rights reserved.
//  游戏主场景

#import "GameScene.h"
#import "CrashLog.h"


@interface GameScene (Private)

- (void) endGame;

@end

@implementation GameScene

@synthesize gameLayer;
@synthesize menuLayer;

- (id) init
{
	self = [super init];
	
	if (self)
	{
        
//#ifdef  DEBUG
        
        
       // [CrashLog start];//用于反馈crash日志 7.12
        
        
//#endif
        
        
        Log_Debug(@"loading game!");
        
        GameLayer *layer = [[GameLayer alloc] init];
		self.gameLayer = layer;
		[layer release];
		
		gameLayer.delegate = self;
		
		[self addChild:gameLayer];
		
		[self endGame];
	}
	
	return self;
}
- (void) endGame
{
	Log_Debug(@"game end!");
    Log_Debug(@"显示菜单");
    if(menuLayer == nil)
	{
		MenuLayer *menu = [[MenuLayer alloc] init];
		self.menuLayer = menu;
		[menu release];
		
		menuLayer.delegate = self;
	}
	
	[self addChild:menuLayer];
}

- (void) restartGame
{
	Log_Debug(@"game start!");
    
    if(menuLayer != nil){
        [self removeChild:menuLayer cleanup:NO];
    }
	[gameLayer restartGame];
	
}
- (void) continueGames
{
    Log_Debug(@"game continue!");
    
    if(menuLayer != nil){
        [self removeChild:menuLayer cleanup:NO];
    }
	[gameLayer continueGames];
}
- (void) saveGames
{
    Log_Debug(@"game saveGames!");
    
    [gameLayer saveGames];
}



- (void) dealloc
{
	
	[menuLayer release];
	[gameLayer release];
	[super dealloc];
}



@end
